﻿using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using yncTech.Common;
using yncTech.BusinessObjects;

public partial class Admin_FinLend_FinLend004a : AdminBasePage
{
    decimal? lendId;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["lendId"] != null)
        {
            lendId = decimal.Parse(Request.QueryString["lendId"]);
        }
        if (!IsPostBack)
        {
            if (lendId.HasValue)
            {
                FinLend finLend = new FinLend();
                if (finLend.LoadByPrimaryKey(lendId.Value))
                {
                    drpLendType.SelectedValue = finLend.LendType;
                    switch (drpLendType.SelectedValue)
                    {
                        case "LendType1":
                            tr1.Visible = false;
                            tr2.Visible = false;
                            trSW.Visible = true;
                            break;
                        case "LendType2":
                            tr1.Visible = false;
                            tr2.Visible = false;
                            trSW.Visible = true;
                            break;
                        case "LendType3":
                            tr1.Visible = false;
                            tr2.Visible = false;
                            trSW.Visible = false;
                            break;
                        case "LendType4":
                            tr1.Visible = false;
                            tr2.Visible = false;
                            trSW.Visible = false;
                            break;
                        case "LendType5":
                            tr1.Visible = true;
                            tr2.Visible = true;
                            trSW.Visible = false;
                            break;
                    }
                }

            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        FinLend finLend = new FinLend();
        finLend.LoadByPrimaryKey(lendId.Value);
        switch (drpLendType.SelectedValue)
        {
            case "LendType1":
                finLend.ActReturnDate = DateTime.Parse(txtReturnDate.Value);
                break;
            case "LendType2":
                finLend.ActReturnDate = DateTime.Parse(txtReturnDate.Value);
                break;
            case "LendType3":
                break;
            case "LendType4":
                break;
            case "LendType5":
                finLend.ActLendDate = DateTime.Parse(txtLendDate.Text.Trim());
                //finLend.act
                break;
        }
        finLend.LendStatus = "LendStatus006";
        finLend.Save();
        WebHelper.CloseDialog(true);
    }
}